﻿using System;
using BLL;
using BLL.A;
using Model.A;

public partial class ActiveProductTrace_ManageActiveProduct_ManageAppearanceCheck_AppearanceCheckAdd : System.Web.UI.Page
{
    AppearanceCheck pjc;

    public ActiveProductTrace_ManageActiveProduct_ManageAppearanceCheck_AppearanceCheckAdd()
    {
        pjc = new AppearanceCheck();
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindJointingFailure();
        }
    }

    protected void BindJointingFailure()
    {
        JointingFailure jf = new JointingFailure();
        this.DropDownList1.DataSource = jf.JointingFailure_GetbyApp();
        this.DropDownList1.DataValueField = "FailureName";
        this.DropDownList1.DataTextField = "FailureName";
        this.DropDownList1.DataBind();
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        string sn = this.TextBox1.Text.Trim();
        AppearanceCheckInfo pjci = new AppearanceCheckInfo(sn, DateTime.Now, User.Identity.Name, this.DropDownList1.SelectedValue);
        try
        {
            pjc.Insert(pjci);
            this.TextBox1.Text = "";
            this.TextBox1.Focus();
            string str = sn + " 录入成功！";
            ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script>alert('" + str + "');</script>");
        }
        catch
        {
            string str = "出现错误，请联系相关人员！";
            ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script>alert('" + str + "');</script>");
        }
    }

    protected void Button2_Click(object sender, EventArgs e)
    {
        string productSN = this.TextBox2.Text.Trim();
        this.GridView1.DataSource = pjc.AppearanceCheck_GetbySN(productSN);
        this.GridView1.DataBind();
    }
}
